@import '../style/theme/color';
@import '../style/theme/font';
@import '../style/core/animation';

:host {
  display: inline-block;
  font-size: 0;
  vertical-align: middle;
}

.devui-toggle {
  width: 36px;
  height: 18px;
  border-radius: (20px/2);
  background: $devui-line;
  border: 1px solid $devui-line;
  position: relative;
  display: inline-block;
  box-sizing: content-box;
  overflow: visible;
  padding: 0;
  margin: 0;
  cursor: pointer;
  transition: $devui-animation-duration-slow $devui-animation-ease-in-smooth all;

  &:not(.devui-checked):hover {
    border-color: $devui-line;
  }

  &:active {
    border-color: $devui-brand-active-focus;
  }

  &.devui-checked:hover {
    border-color: $devui-brand-active;
  }

  .devui-toggle-inner-wrapper {
    display: inline-block;
    width: 100%;
    height: 100%;
    padding-left: 16px;
    font-size: $devui-font-size;

    .devui-toggle-inner {
      width: 100%;
      height: 100%;
      text-align: center;
      color: $devui-light-text;
    }
  }

  &.devui-checked .devui-toggle-inner-wrapper {
    padding-left: unset;
    padding-right: 16px;
  }

  small {
    width: 16px;
    height: 16px;
    background: $devui-light-text;
    border-radius: 100%;
    position: absolute;
    top: 1px;
    left: 1px;
    transition: $devui-animation-duration-slow $devui-animation-ease-in-smooth all;
  }

  &.devui-checked small {
    left: 19px;
  }

  &.devui-toggle-lg {
    width: 58px;
    height: 30px;
    border-radius: (32px/2);

    .devui-toggle-inner-wrapper {
      padding-left: 28px;
      font-size: $devui-font-size-modal-title;
    }

    &.devui-checked .devui-toggle-inner-wrapper {
      padding-left: unset;
      padding-right: 28px;
    }

    & small {
      width: 28px;
      height: 28px;
      top: 1px;
      left: 1px;
    }

    &.devui-checked small {
      background: $devui-light-text;
      left: 29px;
    }
  }

  &.devui-toggle-sm {
    width: 30px;
    height: 14px;
    border-radius: (16px/2);

    .devui-toggle-inner-wrapper {
      padding-left: 12px;
      font-size: $devui-font-size;
    }

    &.devui-checked .devui-toggle-inner-wrapper {
      padding-left: unset;
      padding-right: 12px;
    }

    & small {
      width: 12px;
      height: 12px;
      position: absolute;
    }

    &.devui-checked small {
      left: 17px;
    }
  }

  &.devui-checked {
    background: $devui-brand;
    border-color: $devui-brand;

    &:hover {
      background: $devui-brand-active;
      border-color: $devui-brand-active;
    }

    &:active {
      background: $devui-brand-active-focus;
      border-color: $devui-brand-active-focus;
    }
  }

  &.devui-disabled {
    &,
    &:hover,
    &:active,
    &.devui-checked {
      cursor: not-allowed;
    }

    &,
    &:hover,
    &:active {
      background-color: $devui-disabled-line;
      border-color: $devui-disabled-line;

      small {
        background-color: $devui-unavailable;
      }
    }

    &.devui-checked {
      background-color: $devui-icon-fill-active-disabled;
      border-color: $devui-icon-fill-active-disabled;

      small {
        background-color: $devui-light-text;
      }
    }
  }
}
